package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test8_entity;
import edu.xidian.sselab.cloudcourse.repository.test8_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;

@Controller
public class test8_controller {
    @Autowired
    private test8_Repository test8_repository;

    @RequestMapping("test8")
    public String test8_try(Model model) throws IOException {

        List<test8_entity> recordList = test8_repository.find();

        System.out.println("以下是各国系汽车销量TOP5，按照销售量的倒序排序：");
        for(test8_entity t:recordList){
            System.out.println(t);
        }
        model.addAttribute("title", "各系轿车销量TOP5");
        return "test8";
    }

    @RequestMapping("test24")
    public @ResponseBody
    List test8_try2() throws IOException {

        List<test8_entity> recordList = test8_repository.find();

        System.out.println("以下是各国系汽车销量TOP5，按照销售量的倒序排序：");
        for(test8_entity t:recordList){
            System.out.println(t);
        }
        return recordList;
    }
}
